<?php

namespace App\Http\Controllers\v1;

use App\Model\CardModel;
use App\Model\FavoriteModel;
use App\Model\ImageModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;

class MyFavoriteController extends BaseController
{
    //获取收藏的
    public function get(Request $request){
        $token = $request->header('token');
        $uuid =  Cache::get($token)['uuid'];

        $uidlist = FavoriteModel::where(['uid'=>$uuid])->get();
        $data =[];
        foreach ($uidlist as $k=>$v){
            $data[$k]['card']=CardModel::find($v['cid']);
            $data[$k]['card']['imgs']=ImageModel::where('cid','=',$v['cid'])->get();
        }
        return $this->success('收藏',$data,200);
    }


}
